

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script type="text/javascript" src="helpman_topicinit.js"></script>

<title>Create Search Definitions [Enterprise Architect User Guide]</title>

<meta name="keywords" content="Enterprise Architect, Sparx Systems, UML, Search,Search Project, Create Search Definition,Create,Create Search Definition,Search,Search Definitions, New,Search Query, New,Search Macros, SQL,New Search Query,Query Builder,Query Builder Search Definition,Add-In,Add-In Search,SQL,SQL Editor,SQL Custom Searches,SQL Search Macros,SQL Search, SELECT Statements,Project Search,Project Search Create Search Definition,Model Search,Model Search Create Search Definition,SELECT Statement,SELECT Statement SQL Search,Macros,Macros SQL Search">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<link type="text/css" href="default.css" rel="stylesheet" />
<style type="text/css">
  A, A:Visited
  {
    color: #00F;
  }

  A:Active, A:Hover
  {
    color: #F00;
  }

  OL
  {
    margin: 5px 0 5px 48px;
  }

  UL
  {
    margin-bottom: 3px;
    margin-top: 0;
  }

  #nsr
  {
    background-color: #D4DFFF;
  }

  #nsr A
  {
    text-decoration: none;
  }

  #mainbody
  {
    padding: 8px;
  }

  .p_BodyText
  {
    padding: 5px 0;
  }
</style>



<style type="text/css" media="screen">
  BODY
  {
    background-color: #FFFFFF;
  }

  #nsr
  {
    padding: 6px 6px 0 6px;
    border-bottom: none;
    vertical-align: top;
    z-index: 2;
    visibility: visible;
    left: 0;
    top: 0;
    position: absolute;
  }

  #mainbody
  {
    left: 0;
    top: 0;
    margin: 0;
    position: absolute;
    padding: 10px;
    overflow: auto;
    height: 100%;
    z-index: 1;
    background-repeat: no-repeat;
    background-position: bottom right;
    background-attachment: fixed;
  }
</style>

<style type="text/css" media="print">
  #nsr
  {
    visibility: none;
  }

  #mainbody
  {
    overflow: visible;
  }
</style>
<script type="text/javascript" language="JavaScript" src="nonscroll.js"></script>

</head>
<body scroll="no">

<div id="page">



        <div id="content">
          <div id="content-inner">
          



  
          <div id="nsr">
            <table border="0" cellspacing="0" cellpadding="4" width="100%">
              <tr valign="top">
                <td align="left">
  


                  <p class="p_Heading1"><span class="f_Heading1">Create Search Definitions</span></p>



  
                </td>
                <td align="right">
                  <a href="introduction.htm" onmouseover="document.images.main.src='button_main_h.gif'" onmouseout="document.images.main.src='button_main.gif'">
                    <img name="main" src="button_main.gif" border=0 alt="Return to Introduction">
                  </a>&nbsp;
    
                  <a href="creating_search_filters.htm" onmouseover="document.images.prev.src='button_prev_h.gif'" onmouseout="document.images.prev.src='button_prev.gif'">
                    <img name=prev src="button_prev.gif" border=0 alt="Previous page" />
                  </a>&nbsp;
    
    
    
                  <a href="pre_defined_search_definitions.htm" onmouseover="document.images.next.src='button_next_h.gif'" onmouseout="document.images.next.src='button_next.gif'">
                    <img name=next src="button_next.gif" border=0 alt="Next page" />
                  </a>
    
    
                </td>
              </tr>
            </table>
          </div>
          <div id="mainbody">
  


                <p class="p_BodyText"><span class="f_BodyText"><a href="creating_search_filters.htm">Search definitions</a> are created using the </span><span class="f_UIControl">Manage Searches</span><span class="f_BodyText"> dialog. To access this dialog:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1">Click on the </span><span class="f_MenuKeyField">Options</span><span class="f_Bulletlist1"> button in the </span><span class="f_UIControl"><a href="searching_report_view.htm">Model Search</a></span><span class="f_Bulletlist1"> and then on the </span><span class="f_MenuKeyField">Manage Searches</span><span class="f_Bulletlist1"> menu option, or</span></li>
<li><span class="f_Bulletlist1">Select the </span><span class="f_MenuKeyField"><a href="searchingaproject.htm">Edit | Find in Model</a></span><span class="f_Bulletlist1"> menu option, then click on the </span><span class="f_MenuKeyField">Manage Searches</span><span class="f_Bulletlist1"> button.</span></li>
</ul>
<p class="p_BodyText"><span class="f_BodyText">To create a new search definition, follow the steps below:</span></p>
<ol style="text-indent: 0px; margin-left: 48px; list-style-position: outside;">
<li value=1><span class="f_NumberedList">Click on the </span><span class="f_MenuKeyField">New Search</span><span class="f_NumberedList"> button. The </span><span class="f_UIControl">Create New Search Query</span><span class="f_NumberedList"> dialog displays.</span><br>
<span class="f_NumberedList">&nbsp;</span><br>
<img src="createnewsearchquery.png" width="351" height="136" border="0" alt="CreateNewSearchQuery"><br>
<span class="f_NumberedList">&nbsp;</span></li>
<li value=2><span class="f_NumberedList">In the </span><span class="f_MenuKeyField">Search Name</span><span class="f_NumberedList"> field, type a name for your new search.</span></li>
<li value=3><span class="f_NumberedList">Select the radio button for the type of search you require:</span></li>
</ol>
<ul style="text-indent: 0px; margin-left: 65px; list-style-position: outside;">
<li><span class="f_Bulletlist3">The </span><span class="f_MenuKeyField"><a href="creating_filters.htm#Query">Query Builder</a></span><span class="f_Bulletlist3"> option provides an interface that enables you to design your own search.</span></li>
<li><span class="f_Bulletlist3">The </span><span class="f_MenuKeyField"><a href="creating_filters.htm#SQL">SQL Editor</a></span><span class="f_Bulletlist3"> option enables advanced users to directly write SQL Select statements.</span></li>
<li><span class="f_Bulletlist3">The </span><span class="f_MenuKeyField"><a href="creating_filters.htm#Add-In">Add-In Search</a></span><span class="f_Bulletlist3"> option enables you to supply the name of your Add-In and a method (e.g. </span><span class="f_Bulletlist3" style="font-style: italic;">MyAddin.RunThisMethod</span><span class="f_Bulletlist3">)</span><span class="f_Bulletlist3">. This method is called whenever the search is run. This search can be exported and distributed as a part of your Add-In. For more information, see </span><span class="f_Bulletlist3" style="font-style: italic;"><a href="addins_2.htm">Add-Ins</a></span><span class="f_Bulletlist3">.</span></li>
</ul>
<ol style="text-indent: 0px; margin-left: 48px; list-style-position: outside;">
<li value=4><span class="f_NumberedList">Click on the </span><span class="f_MenuKeyField">OK</span><span class="f_NumberedList"> button.</span></li>
</ol>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Query Builder<a name="query"></a></span></p>
<p class="p_BodyText"><span class="f_BodyText">Your search definition now appears as being selected in the </span><span class="f_MenuKeyField">Search List</span><span class="f_BodyText"> drop-down. The main window displays the message </span><span class="f_BodyText" style="font-style: italic;">'There are no items to show in this view'</span><span class="f_BodyText">. You can now click on the </span><span class="f_MenuKeyField">Add Filter</span><span class="f_BodyText"> button to <a href="adding_filters.htm">Add Filters</a>.</span></p>
<p class="p_TextIndentedL2"><img src="searchproject-create%20definitions.png" width="676" height="387" border="0" alt="SearchProject-Create Definitions"></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">SQL Editor<a name="sql"></a></span></p>
<p class="p_BodyText"><span class="f_BodyText">The </span><span class="f_UIControl">Custom SQL</span><span class="f_BodyText"> dialog displays, enabling you to input your </span><span class="f_BodyText" style="font-style: italic;">SELECT</span><span class="f_BodyText"> statement. </span><span class="f_BodyText">The SQL editor is based on the common Code Editor, and provides an Intellisense </span><span class="f_BodyText" style="font-style: italic;">autocompletion list</span><span class="f_BodyText"> populated with Enterprise Architect's repository structure. You can display the autocompletion list by pressing </span><span class="f_MenuKeyField">[Ctrl]+[Spacebar]</span><span class="f_BodyText">. </span></p>
<p class="p_BodyText"><span class="f_BodyText">For more details on Intellisense and the common Code Editor, see the <a href="code_editors.htm">Code Editors</a> topic.</span></p>
<p class="p_TextIndentedL2"><img src="custom%20sql%20search%20dialog.png" width="727" height="451" border="0" alt="Custom SQL Search Dialog"></p>
<p class="p_BodyText"><span class="f_BodyText">Enterprise Architect also enables you to use #xxx# macros as string replacers in WHERE statements, so that the same search can be used by different people in different environments. These macros include:</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1" style="font-style: italic;">#WC#</span><span class="f_Bulletlist1"> - Gets the appropriate wild card for the current database, and so enables the search to be performed on models on different databases; for example, </span><span class="f_Bulletlist1" style="font-style: italic;">t_object.Name LIKE '#WC#Test#WC#'</span></li>
</ul>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1" style="font-style: italic;">#Author#</span><span class="f_Bulletlist1"> - Takes the value of the </span><span class="f_MenuKeyField">Author</span><span class="f_Bulletlist1"> field in the </span><span class="f_UIControl">Options</span><span class="f_Bulletlist1"> dialog </span><span class="f_UIControl">General</span><span class="f_Bulletlist1"> page, and enables the defined search to be performed on objects created by that user (this value can be manually re-set in the </span><span class="f_UIControl">Options</span><span class="f_Bulletlist1"> dialog)</span></li>
</ul>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1" style="font-style: italic;">#DB=&lt;DBNAME&gt;# </span><span class="f_Bulletlist1">where </span><span class="f_Bulletlist1" style="font-style: italic;">&lt;DBNAME</span><span class="f_Bulletlist1">&gt; can be one of the following:</span></li>
</ul>
<ul style="text-indent: 0px; margin-left: 65px; list-style-position: outside;">
<li><span class="f_Bulletlist3">MYSQL </span></li>
<li><span class="f_Bulletlist3">JET </span></li>
<li><span class="f_Bulletlist3">ORACLE </span></li>
<li><span class="f_Bulletlist3">SQLSVR </span></li>
<li><span class="f_Bulletlist3">ASA </span></li>
<li><span class="f_Bulletlist3">OPENEDGE </span></li>
<li><span class="f_Bulletlist3">POSTGRES.</span></li>
</ul>
<p class="p_Bulletlist1"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="f_Bulletlist1">For example, </span><span style="font-size: 10pt; font-style: italic; color: #000000;">#DB=ORACLE# t_object.ModifiedDate &gt;= (SYSDATE - INTERVAL '&lt;Search Term&gt;' DAY)</span></p>
<ul style="text-indent: 0px; margin-left: 30px; list-style-position: outside;">
<li><span class="f_Bulletlist1" style="font-style: italic;">#UserName#</span><span class="f_Bulletlist1"> - Gets the name of the person logged into version control; for example, </span><span class="f_Bulletlist1" style="font-style: italic;">t_package.PackageFlags LIKE '#WC#VCCFG=#WC#CheckedOutTo=#UserName##WC#'</span><span class="f_Bulletlist1"> (this is from Enterprise Architect's built in search </span><span class="f_Bulletlist1" style="font-style: italic;">My Checked Out Packages).</span></li>
</ul>
<p class="p_BodyText"><span class="f_Bulletlist1">&nbsp;</span></p>
<div style="text-align: left; text-indent: 0px; padding: 0px 0px 0px 0px; margin: 5px 0px 5px 13px;"><table cellspacing="0" cellpadding="2" border="0" style="border: none; border-spacing:0px;">
<tr style="text-align:left;vertical-align:bottom;">
<td valign="bottom" width="952" bgcolor="#efeff7" style="width:952px; background-color:#efeff7;"><p class="p_TiporNote" style="border-top: none; border-right: none; border-left: none;"><span class="f_TiporNote">Note:</span></p>
</td>
</tr>
<tr style="text-align:left;">
<td width="952" bgcolor="#f7f7ff" style="width:952px; background-color:#f7f7ff;"><p class="p_TiporNoteText"><span class="f_TiporNoteText">For all Enterprise Architect functions in which you use a custom </span><span class="f_TiporNoteText">SQL statement (such as RTF reporting or Model Views) the statement must return the </span><span class="f_TiporNoteText" style="font-style: italic;">guid</span><span class="f_TiporNoteText"> and</span><span class="f_TiporNoteText"> </span><span class="f_TiporNoteText" style="font-style: italic;">type</span><span class="f_TiporNoteText"> of the object found so that Enterprise Architect can search for the selected item in the </span><span class="f_UIControl">Project Browser</span><span class="f_TiporNoteText">. For example:</span></p>
<p class="p_TiporNoteText"><span class="f_TiporNoteText" style="font-style: italic;">SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name FROM t_object</span></p>
</td>
</tr>
</table>
</div>
<p class="p_BodyText"><span class="f_BodyText">You can display an item's properties by simply double-clicking on a table name in the </span><span class="f_UIControl">Table Name</span><span class="f_BodyText"> list, and executing the </span><span class="f_BodyText" style="font-style: italic;">SELECT</span><span class="f_BodyText"> statement that displays for that table in the </span><span class="f_UIControl">Query</span><span class="f_BodyText"> panel. For example:</span></p>
<p class="p_BodyText"><span class="f_BodyText" style="font-style: italic;">SELECT * FROM t_object WHERE NAME=&lt;Search Term&gt;'</span></p>
<p class="p_BodyText"><span class="f_BodyText">You can extend the usability of your SQL searches using the aliases </span><span class="f_BodyText" style="font-style: italic;">CLASSGUID</span><span class="f_BodyText"> and </span><span class="f_BodyText" style="font-style: italic;">CLASSTYPE</span><span class="f_BodyText">. These enable Enterprise Architect to display the </span><span class="f_UIControl">Properties</span><span class="f_BodyText"> dialog and icon for elements, connectors, attributes or operations, as well as selecting them in the </span><span class="f_UIControl">Project Browser</span><span class="f_BodyText">. Some simple examples for using these aliased fields are provided below:</span></p>
<p class="p_BodyText"><span class="f_BodyText" style="font-style: italic;">SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name FROM t_object</span></p>
<p class="p_BodyText"><span class="f_BodyText" style="font-style: italic;">SELECT ea_guid AS CLASSGUID, Connector_Type AS CLASSTYPE, Name FROM t_connector</span></p>
<p class="p_BodyText"><span class="f_BodyText" style="font-style: italic;">SELECT ea_guid AS CLASSGUID, 'Operation' AS CLASSTYPE, Name FROM t_operation</span></p>
<p class="p_BodyText"><span class="f_BodyText" style="font-style: italic;">SELECT ea_guid AS CLASSGUID, 'Attribute' AS CLASSTYPE, Name FROM t_attribute.</span></p>
<p class="p_BodyText"><span class="f_BodyText">When you have defined the </span><span class="f_BodyText" style="font-style: italic;">SELECT</span><span class="f_BodyText"> statement, click on the </span><span class="f_MenuKeyField">Save</span><span class="f_BodyText"> button to save this search. The search is then available from the </span><span class="f_MenuKeyField">Search List</span><span class="f_BodyText">.</span></p>
<p class="p_SubHeadingL1"><span class="f_SubHeadingL1">Add-In Search<a name="add-in"></a></span></p>
<p class="p_BodyText"><span class="f_BodyText">Type in the field the name of your Add-In, a period (full stop) and then the name of the method to be called (e.g. </span><span class="f_BodyText" style="font-style: italic;">MyAddin.RunThisMethod</span><span class="f_BodyText">). </span><span class="f_BodyText">Your search is automatically saved and available from the </span><span class="f_MenuKeyField">Search List</span><span class="f_BodyText">.</span></p>




            </div>
          </div>
        </div>



</div>


</body>
</html>
